import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:library_base/constant/constant.dart';
import 'package:library_base/ext/theme_data_ext.dart';
import 'package:library_base/global/multi_language.dart';
import 'package:library_base/res/styles.dart';
import 'package:library_base/utils/theme_util.dart';
import 'package:module_wms/page/outbound_orders/as_order/order_detail/inventory_distribution/base_inventory_distribution_page.dart';
import 'package:module_wms/page/outbound_orders/as_order/order_detail/inventory_distribution/inventory_distribution_single/inventory_distribution_single_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class InventoryDistributionSinglePage extends StatefulWidget {
  const InventoryDistributionSinglePage({Key? key}) : super(key: key);

  @override
  InventoryDistributionSinglePageState createState() => InventoryDistributionSinglePageState();

}

class InventoryDistributionSinglePageState
    extends BaseInventoryDistributionPageState<InventoryDistributionSinglePage, InventoryDistributionSingleController> {

  var itemWidths = <double>[];

  @override
  void onCreate() {
    super.onCreate();
    if(Constant.isShowSeat){
      itemWidths = <double>[200.w,200.w,200.w];
    }else{
      itemWidths = <double>[300.w,300.w];
    }
  }

  @override
  InventoryDistributionSingleController? registerController() => Get.find<InventoryDistributionSingleController>();

  @override
  double getLeftTitleWidth()=> 150.w;

  @override
  double getTitleWidth(int i) => itemWidths[i];

  @override
  buildRightContent(int dataIndex) {
    List<Widget> list = [];
    for (int i = 0; i < titleList.length; i++) {
      list.add(Container(
        alignment: const Alignment(0, 0),
        decoration: BoxDecoration(
            border: Border(
                bottom: BorderSide(
                    color: ThemeUtil.getTheme().dividingLineColor(),
                    width: 0.7))),
        width: itemWidths[i%(Constant.isShowSeat?3:2)],
        height: getCellHeight(),
        child: Text(
          getColumnContentStr(i%(Constant.isShowSeat?3:2),dataIndex),
          style: normalTextColor24,
        ),
      ));
    }
    return list;
  }

  String getColumnContentStr(int index,int dataIndex){
    if(index == 0){
      return baseGetxController!.goodsDetails[dataIndex].goodsBarCode;
    }else if(index == 1){
      return goodsName;
    }else{
      return baseGetxController!.goodsDetails[dataIndex].locationName;
    }
  }

  @override
  double getRightRowWidth() {
   return 750.w - getLeftTitleWidth();
  }

  @override
  List<String> getTitleList() {
    if(Constant.isShowSeat){
      return [MultiLanguage.barCodeWithN.tr,MultiLanguage.productName.tr,MultiLanguage.seat.tr];
    }else{
      return [MultiLanguage.barCodeWithN.tr,MultiLanguage.productName.tr];
    }
  }

}
